package demo;

import java.util.HashMap;
import java.util.concurrent.CountDownLatch;

public class HashMapTest {
    public static void main(String[] args) throws InterruptedException {
        final HashMap<Integer, String> hashMap = new HashMap<>(8);

        CountDownLatch countDownLatch = new CountDownLatch(2);
        new Thread(() -> {
            hashMap.put(1, "1");
            countDownLatch.countDown();
        }).start();

        new Thread(() -> {
            hashMap.put(9, "9");
            countDownLatch.countDown();
        }).start();

        countDownLatch.await();
        System.out.println(hashMap.get(1));
        System.out.println(hashMap.get(9));
        System.out.println(hashMap.size());
    }
}
